package org.gdstash.ui.table;

import org.gdstash.character.GDChar;
import org.gdstash.util.GDMsgFormatter;

import javax.swing.*;
import javax.swing.table.TableCellEditor;

public class GDDevotionRow {
    public static final Class[] COLUMN_CLASSES;
    public static String[] columnNames;
    public GDChar.SkillInfo devotion;
    public int maxLevel;
    public TableCellEditor editor;

    public GDDevotionRow(final GDChar.SkillInfo devotion, final int maxLevel) {
        this.devotion = devotion;
        this.maxLevel = maxLevel;
        if (maxLevel > 0) {
            final JComboBox<String> cbLevels = new JComboBox<String>();
            for (int i = 1; i <= maxLevel; ++i) {
                cbLevels.addItem(Integer.toString(i));
            }
            this.editor = new DefaultCellEditor(cbLevels);
        }
    }

    public static void updateColumnNames() {
        if (GDDevotionRow.columnNames == null) {
            GDDevotionRow.columnNames = new String[2];
        }
        GDDevotionRow.columnNames[0] = GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_COL_DEVOTION");
        GDDevotionRow.columnNames[1] = GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_COL_LEVEL");
    }

    static {
        COLUMN_CLASSES = new Class[]{String.class, String.class};
        GDDevotionRow.columnNames = null;
        updateColumnNames();
    }
}
